package easy;

/**
 * @author admin
 * 1716. 计算力扣银行的钱
 * 解题思路：数学公式
 */
public class LeeCode1716 {

    public int totalMoney(int n) {

/*
输入：n = 20
输出：96
解释：第 20 天后，总额为 (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96 。
 */

//        共几周
        int week = n / 7;
//        剩几天
        int day = n % 7;
        return 28*week + week*(week - 1)*7/2 + (week + 1 + week + day)*(day)/2;

    }

    public static void main(String[] args) {
        System.out.println(new LeeCode1716().totalMoney(20));
    }
}
